const path = require('path');
const { merge } = require('webpack-merge');

const webpackCommon = require('./webpack.common');
const vueConfig = require('./feature/vue.config');
const reactConfig = require('./feature/react.config');

module.exports = function(calcConfig){
    const moduleConfig = require(path.join(calcConfig.modulePath, 'config.js'));
    const type = moduleConfig.type;
    
  const configArray = [webpackCommon(calcConfig, moduleConfig)];

  configArray.push( type === 'vue' ? vueConfig(calcConfig) : reactConfig(calcConfig) );

  configArray.push({
      mode: 'development',
      devtool: 'cheap-module-eval-source-map',
      output: {
          publicPath: '/'
      },
  });

  return merge(...configArray);
}